﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using YXShop.IDAL.Product;
using System.Collections.Generic;

namespace YXShop.SQLServerDAL.Product
{
    /// <summary>
    /// 数据访问类ProductInfo。
    /// </summary>
    public class ProductInfo :DbBase, IProductInfo
    {
        
        #region "DataBase Operation"

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(YXShop.Model.Product.ProductInfo model)
        {
            SqlParameter[] paras = (SqlParameter[])this.ValueParas(model);
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into "+Pre+"product(");
            strSql.Append("pro_Property,cid,pro_BrandID,pro_Name,pro_NO,pro_ShopPrice,pro_MarketPrice,pro_RatingDiscount,pro_DonateIntegral,pro_Thumbnail,pro_Images,pro_Original,pro_Synopsis,pro_Content,pro_MetaKeywords,pro_MetaDescription,pro_MetaTitle,pro_Weight,pro_Stock,pro_Unit,pro_Alarm,pro_AuditCount,pro_Audit,pro_State,pro_Designation,pro_RelatingproID,pro_RelatingArtID,pro_UpdateTime,pro_OnClicks,pro_SaleNum,pro_CostPrice,pro_AutoUp,pro_AutoDown,pro_IntegralPrice,pro_Area,pro_PutoutID,pro_PutoutType,pro_ContentTemplate,pro_Specifications,pro_Parameters,pro_Type,pro_Specialspecifications)");
            strSql.Append(" values (");
            strSql.Append("@pro_Property,@cid,@pro_BrandID,@pro_Name,@pro_NO,@pro_ShopPrice,@pro_MarketPrice,@pro_RatingDiscount,@pro_DonateIntegral,@pro_Thumbnail,@pro_Images,@pro_Original,@pro_Synopsis,@pro_Content,@pro_MetaKeywords,@pro_MetaDescription,@pro_MetaTitle,@pro_Weight,@pro_Stock,@pro_Unit,@pro_Alarm,@pro_AuditCount,@pro_Audit,@pro_State,@pro_Designation,@pro_RelatingproID,@pro_RelatingArtID,@pro_UpdateTime,@pro_OnClicks,@pro_SaleNum,@pro_CostPrice,@pro_AutoUp,@pro_AutoDown,@pro_IntegralPrice,@pro_Area,@pro_PutoutID,@pro_PutoutType,@pro_ContentTemplate,@pro_Specifications,@pro_Parameters,@pro_Type,@pro_Specialspecifications)");
            strSql.Append(";select @@IDENTITY");
            object obj = ChangeHope.DataBase.SQLServerHelper.GetSingle(strSql.ToString(), paras);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(YXShop.Model.Product.ProductInfo model)
        {
            SqlParameter[] paras = (SqlParameter[])this.ValueParas(model);
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update " + Pre + "product set ");
            strSql.Append("pro_Property=@pro_Property,");
            strSql.Append("cid=@cid,");
            strSql.Append("pro_BrandID=@pro_BrandID,");
            strSql.Append("pro_Name=@pro_Name,");
            strSql.Append("pro_NO=@pro_NO,");
            strSql.Append("pro_ShopPrice=@pro_ShopPrice,");
            strSql.Append("pro_MarketPrice=@pro_MarketPrice,");
            strSql.Append("pro_RatingDiscount=@pro_RatingDiscount,");
            strSql.Append("pro_DonateIntegral=@pro_DonateIntegral,");
            strSql.Append("pro_Thumbnail=@pro_Thumbnail,");
            strSql.Append("pro_Images=@pro_Images,");
            strSql.Append("pro_Original=@pro_Original,");
            strSql.Append("pro_Synopsis=@pro_Synopsis,");
            strSql.Append("pro_Content=@pro_Content,");
            strSql.Append("pro_MetaKeywords=@pro_MetaKeywords,");
            strSql.Append("pro_MetaDescription=@pro_MetaDescription,");
            strSql.Append("pro_MetaTitle=@pro_MetaTitle,");
            strSql.Append("pro_Weight=@pro_Weight,");
            strSql.Append("pro_Stock=@pro_Stock,");
            strSql.Append("pro_Unit=@pro_Unit,");
            strSql.Append("pro_Alarm=@pro_Alarm,");
            strSql.Append("pro_AuditCount=@pro_AuditCount,");
            strSql.Append("pro_Audit=@pro_Audit,");
            strSql.Append("pro_State=@pro_State,");
            strSql.Append("pro_Designation=@pro_Designation,");
            strSql.Append("pro_RelatingproID=@pro_RelatingproID,");
            strSql.Append("pro_RelatingArtID=@pro_RelatingArtID,");
            strSql.Append("pro_UpdateTime=@pro_UpdateTime,");
            strSql.Append("pro_OnClicks=@pro_OnClicks,");
            strSql.Append("pro_SaleNum=@pro_SaleNum,");
            strSql.Append("pro_CostPrice=@pro_CostPrice,");
            strSql.Append("pro_AutoUp=@pro_AutoUp,");
            strSql.Append("pro_AutoDown=@pro_AutoDown,");
            strSql.Append("pro_IntegralPrice=@pro_IntegralPrice,");
            strSql.Append("pro_Area=@pro_Area,");
            strSql.Append("pro_PutoutID=@pro_PutoutID,");
            strSql.Append("pro_PutoutType=@pro_PutoutType,");
            strSql.Append("pro_ContentTemplate=@pro_ContentTemplate,");
            strSql.Append("pro_Specifications=@pro_Specifications,");
            strSql.Append("pro_Parameters=@pro_Parameters,");
            strSql.Append("pro_Type=@pro_Type,");
            strSql.Append("pro_Specialspecifications=@pro_Specialspecifications");
            strSql.Append(" where pro_ID=@pro_ID ");
            return ChangeHope.DataBase.SQLServerHelper.ExecuteSql(strSql.ToString(), paras);
        }
        /// <summary>
        /// 任意修改字段
        /// </summary>
        /// <param name="id">商品ID</param>
        /// <param name="columnName">修改字段名</param>
        /// <param name="value">修改的值</param>
        /// <returns></returns>
        public int Amend(int id, string columnName, Object value)
        {
            string sequel = "Update [" + Pre + "product] set ";
            sequel = sequel + "[" + columnName + "] =@value ";
            sequel = sequel + UpdateWhereSequel;
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@value", value), new SqlParameter("@pro_Id", id) };
            object obj = ChangeHope.DataBase.SQLServerHelper.GetSingle(sequel, paras);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 删除一条数据或批量删除
        /// </summary>
        public void Delete(string pro_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from " + Pre + "product ");
            strSql.Append(" where pro_ID in ("+pro_ID+") ");
            ChangeHope.DataBase.SQLServerHelper.ExecuteSql(strSql.ToString());
        }
        public void DeleleById(int pro_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from " + Pre + "product ");
            strSql.Append(" where pro_ID=@id ");
            SqlParameter[] parameters ={
                                           new SqlParameter("@id",SqlDbType.Int,4)
                                       };
            parameters[0].Value = pro_ID;
            ChangeHope.DataBase.SQLServerHelper.ExecuteSql(strSql.ToString(),parameters);
       }

        #endregion

        #region "Data Load"
        public ProductInfo()
        { }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public YXShop.Model.Product.ProductInfo GetModel(int pro_ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 pro_ID,(select [name] from " + Pre + "productclass where " + Pre + "productclass.cid=" + Pre + "product.cid) as ProClassName,pro_Property,cid,pro_BrandID,pro_Name,pro_NO,pro_ShopPrice,pro_MarketPrice,pro_RatingDiscount,pro_DonateIntegral,pro_Thumbnail,pro_Images,pro_Original,pro_Synopsis,pro_Content,pro_MetaKeywords,pro_MetaDescription,pro_MetaTitle,pro_Weight,pro_Stock,pro_Unit,pro_Alarm,pro_AuditCount,pro_Audit,pro_State,pro_Designation,pro_RelatingproID,pro_RelatingArtID,pro_CreateTime,pro_UpdateTime,pro_OnClicks,pro_SaleNum,pro_CostPrice,pro_AutoUp,pro_AutoDown,pro_IntegralPrice,pro_Area,pro_PutoutID,pro_PutoutType,pro_ContentTemplate,pro_Specifications,pro_Parameters,pro_Type,pro_Specialspecifications from " + Pre + "product ");
            strSql.Append(" where pro_ID=@pro_ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@pro_ID", SqlDbType.Int,4)};
            parameters[0].Value = pro_ID;

            YXShop.Model.Product.ProductInfo model = new YXShop.Model.Product.ProductInfo();
            DataSet ds = ChangeHope.DataBase.SQLServerHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["pro_ID"].ToString() != "")
                {
                    model.pro_ID = int.Parse(ds.Tables[0].Rows[0]["pro_ID"].ToString());
                }
                model.ProClassName = ds.Tables[0].Rows[0]["ProClassName"].ToString();
                model.pro_Property = ds.Tables[0].Rows[0]["pro_Property"].ToString();
                model.pro_CID = ds.Tables[0].Rows[0]["cid"].ToString();
                if (ds.Tables[0].Rows[0]["pro_BrandID"].ToString() != "")
                {
                    model.pro_BrandID = int.Parse(ds.Tables[0].Rows[0]["pro_BrandID"].ToString());
                }
                model.pro_Name = ds.Tables[0].Rows[0]["pro_Name"].ToString();
                model.pro_NO = ds.Tables[0].Rows[0]["pro_NO"].ToString();
                if (ds.Tables[0].Rows[0]["pro_ShopPrice"].ToString() != "")
                {
                    model.pro_ShopPrice = decimal.Parse(ds.Tables[0].Rows[0]["pro_ShopPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_MarketPrice"].ToString() != "")
                {
                    model.pro_MarketPrice = decimal.Parse(ds.Tables[0].Rows[0]["pro_MarketPrice"].ToString());
                }
                model.pro_RatingDiscount = ds.Tables[0].Rows[0]["pro_RatingDiscount"].ToString();
                
                if (ds.Tables[0].Rows[0]["pro_DonateIntegral"].ToString() != "")
                {
                    model.pro_DonateIntegral = decimal.Parse(ds.Tables[0].Rows[0]["pro_DonateIntegral"].ToString());
                }
                model.pro_Thumbnail = ds.Tables[0].Rows[0]["pro_Thumbnail"].ToString();
                model.pro_Images = ds.Tables[0].Rows[0]["pro_Images"].ToString();
                model.pro_Original = ds.Tables[0].Rows[0]["pro_Original"].ToString();
                model.pro_Synopsis = ds.Tables[0].Rows[0]["pro_Synopsis"].ToString();
                model.pro_Content = ds.Tables[0].Rows[0]["pro_Content"].ToString();
                model.pro_MetaKeywords = ds.Tables[0].Rows[0]["pro_MetaKeywords"].ToString();
                model.pro_MetaDescription = ds.Tables[0].Rows[0]["pro_MetaDescription"].ToString();
                model.pro_MetaTitle = ds.Tables[0].Rows[0]["pro_MetaTitle"].ToString();
                if (ds.Tables[0].Rows[0]["pro_Weight"].ToString() != "")
                {
                    model.pro_Weight = decimal.Parse(ds.Tables[0].Rows[0]["pro_Weight"].ToString());
                }
                
                if (ds.Tables[0].Rows[0]["pro_Stock"].ToString() != "")
                {
                    model.pro_Stock = int.Parse(ds.Tables[0].Rows[0]["pro_Stock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_Unit"].ToString() != "")
                {
                    model.pro_Unit = ds.Tables[0].Rows[0]["pro_Unit"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pro_Alarm"].ToString() != "")
                {
                    model.pro_Alarm = int.Parse(ds.Tables[0].Rows[0]["pro_Alarm"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_AuditCount"].ToString() != "")
                {
                    model.pro_AuditCount = int.Parse(ds.Tables[0].Rows[0]["pro_AuditCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_Audit"].ToString() != "")
                {
                    model.pro_Audit = int.Parse(ds.Tables[0].Rows[0]["pro_Audit"].ToString());
                }
                model.pro_State = ds.Tables[0].Rows[0]["pro_State"].ToString();
                model.pro_Designation = ds.Tables[0].Rows[0]["pro_Designation"].ToString();
                model.pro_RelatingproID = ds.Tables[0].Rows[0]["pro_RelatingproID"].ToString();
                model.pro_RelatingArtID = ds.Tables[0].Rows[0]["pro_RelatingArtID"].ToString();
                
                if (ds.Tables[0].Rows[0]["pro_UpdateTime"].ToString() != "")
                {
                    model.pro_UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["pro_UpdateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_OnClicks"].ToString() != "")
                {
                    model.pro_OnClicks = int.Parse(ds.Tables[0].Rows[0]["pro_OnClicks"].ToString());
                }
                
                if (ds.Tables[0].Rows[0]["pro_SaleNum"].ToString() != "")
                {
                    model.pro_SaleNum = int.Parse(ds.Tables[0].Rows[0]["pro_SaleNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_CostPrice"].ToString() != "")
                {
                    model.pro_CostPrice = decimal.Parse(ds.Tables[0].Rows[0]["pro_CostPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_AutoUp"].ToString() != "")
                {
                    model.pro_AutoUp = DateTime.Parse(ds.Tables[0].Rows[0]["pro_AutoUp"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_AutoDown"].ToString() != "")
                {
                    model.pro_AutoDown = DateTime.Parse(ds.Tables[0].Rows[0]["pro_AutoDown"].ToString());
                }
                
                if (ds.Tables[0].Rows[0]["pro_IntegralPrice"].ToString() != "")
                {
                    model.pro_IntegralPrice = decimal.Parse(ds.Tables[0].Rows[0]["pro_IntegralPrice"].ToString());
                }
                model.pro_Area = ds.Tables[0].Rows[0]["pro_Area"].ToString();
                if (ds.Tables[0].Rows[0]["pro_PutoutID"].ToString() != "")
                {
                    model.pro_PutoutID = int.Parse(ds.Tables[0].Rows[0]["pro_PutoutID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["pro_PutoutType"].ToString() != "")
                {
                    model.pro_PutoutType = int.Parse(ds.Tables[0].Rows[0]["pro_PutoutType"].ToString());
                }
                
                if (ds.Tables[0].Rows[0]["pro_ContentTemplate"].ToString() != "")
                {
                    model.pro_ContentTemplate = ds.Tables[0].Rows[0]["pro_ContentTemplate"].ToString();
                }

                model.pro_Specifications = ds.Tables[0].Rows[0]["pro_Specifications"].ToString();
                model.pro_Parameters = ds.Tables[0].Rows[0]["pro_Parameters"].ToString();
                if (ds.Tables[0].Rows[0]["pro_Type"].ToString() != "")
                {
                    model.pro_Type = int.Parse(ds.Tables[0].Rows[0]["pro_Type"].ToString());
                }
                model.pro_Specialspecifications = ds.Tables[0].Rows[0]["pro_Specialspecifications"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 所有记录
        /// </summary>
        /// <remarks></remarks>
        public ChangeHope.DataBase.DataByPage GetList()
        {
            ChangeHope.DataBase.DataByPage dataPage = new ChangeHope.DataBase.DataByPage();
            dataPage.Sql = "[select] * [from] " + Pre + "product [where] 1=1 [order by] pro_ID desc";
            dataPage.GetRecordSetByPage();
            return dataPage;
        }
        /// <summary>
        /// 排序所有记录
        /// </summary>
        /// <remarks></remarks>
        public ChangeHope.DataBase.DataByPage GetList(string orderfield, int pagesize, string Conditions)
        {
            ChangeHope.DataBase.DataByPage dataPage = new ChangeHope.DataBase.DataByPage();
            dataPage.Sql = "[select] * [from] " + Pre + "product [where] 1=1 " + Conditions + " " + orderfield;
            dataPage.PageSize = pagesize;
            dataPage.GetRecordSetByPage();
            return dataPage;
        }
        /// <summary>
        /// 获取部分数据
        /// </summary>
        /// <param name="StrID"></param>
        /// <returns></returns>
        public DataTable GetPartData(string StrID)
        {
            string strSql = "Select * From " + Pre + "product where pro_ID in (" + StrID + ")";
            DataTable dt = ChangeHope.DataBase.SQLServerHelper.Query(strSql.ToString()).Tables[0];
            return dt;
        }
        /// <summary>
        /// 获取最大值
        /// </summary>
        /// <returns></returns>
        public int GetMax()
        {
            string strSql = "Select max(pro_ID) From " + Pre + "product";

            object obj = ChangeHope.DataBase.SQLServerHelper.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 根据条件返回集合
        /// </summary>
        /// <param name="where"></param>
        /// <param name="topNumber">为0时查所有</param>
        /// <returns></returns>
        public ChangeHope.DataBase.DataByPage GetListByWhere(string where, int topNumber, int pagesize, string orderfield)
        {
          
            ChangeHope.DataBase.DataByPage dataPage = new ChangeHope.DataBase.DataByPage();

            dataPage.Sql = "[select] * [from] " + Pre + "product [where]  " + where + " [order by] " + orderfield + " ";
             
            if(topNumber>0)
            {
                dataPage.PageSize=topNumber;
            }
            else
            {
                dataPage.PageSize=pagesize;
            }
            dataPage.GetRecordSetByPage();
            return dataPage;
        }
        /// <summary>
        /// 跟据条件返回DataTable
        /// </summary>
        /// <param name="Conditions"></param>
        /// <returns></returns>
        public DataTable dtGetListWhere(string Conditions)
        {
            string Sel = this.SelectSequel + " where 1=1 " + Conditions;
            return ChangeHope.DataBase.SQLServerHelper.Query(Sel).Tables[0];
        }
        /// <summary>
        /// 指字段与条件查询
        /// </summary>
        /// <param name="FieldStr">字段</param>
        /// <param name="Condition"></param>
        /// <returns></returns>
        public DataTable GetAppointField(string FieldStr, string Condition)
        {
            string selectSequel = "Select " + FieldStr + ",1 PersistStatus  From [" + Pre + "product] where 1=1 " + Condition;
            return ChangeHope.DataBase.SQLServerHelper.Query(selectSequel).Tables[0];
        }

        #endregion  
        #region "Other function"
        string selectSequel = string.Empty;
        protected string SelectSequel
        {
            get
            {
                if (selectSequel == string.Empty)
                    selectSequel = "Select *,1 PersistStatus  From [" + Pre + "product] ";
                return selectSequel;
            }
            set
            {
                this.selectSequel = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        protected string UpdateWhereSequel
        {
            get
            {
                return " Where [pro_ID] = @pro_ID";
            }
        }
        /// <summary>
        /// 该数据访问对象的属性值装载到数据库更新参数数组
        /// </summary>
        /// <remarks></remarks>

        public IDbDataParameter[] ValueParas(YXShop.Model.Product.ProductInfo model)
        {
            SqlParameter[] parameters = new SqlParameter[43];
            parameters[0] = new SqlParameter("@pro_ID", SqlDbType.Int, 4);
            parameters[1] = new SqlParameter("@pro_Property", SqlDbType.VarChar, 2000);
            parameters[2] = new SqlParameter("@cid", SqlDbType.VarChar, 1000);
            parameters[3] = new SqlParameter("@pro_BrandID", SqlDbType.Int, 4);
            parameters[4] = new SqlParameter("@pro_Name", SqlDbType.VarChar, 200);
            parameters[5] = new SqlParameter("@pro_NO", SqlDbType.VarChar, 100);
            parameters[6] = new SqlParameter("@pro_ShopPrice", SqlDbType.Float, 8);
            parameters[7] = new SqlParameter("@pro_MarketPrice", SqlDbType.Float, 8);
            parameters[8] = new SqlParameter("@pro_RatingDiscount", SqlDbType.VarChar, 500);
            parameters[9] = new SqlParameter("@pro_DonateIntegral", SqlDbType.Float, 8);
            parameters[10] = new SqlParameter("@pro_Thumbnail", SqlDbType.VarChar, 200);
            parameters[11] = new SqlParameter("@pro_Images", SqlDbType.VarChar, 200);
            parameters[12] = new SqlParameter("@pro_Original", SqlDbType.VarChar, 200);
            parameters[13] = new SqlParameter("@pro_Synopsis", SqlDbType.VarChar, 3000);
            parameters[14] = new SqlParameter("@pro_Content", SqlDbType.Text);
            parameters[15] = new SqlParameter("@pro_MetaKeywords", SqlDbType.VarChar, 200);
            parameters[16] = new SqlParameter("@pro_MetaDescription", SqlDbType.VarChar, 500);
            parameters[17] = new SqlParameter("@pro_MetaTitle", SqlDbType.VarChar, 300);
            parameters[18] = new SqlParameter("@pro_Weight", SqlDbType.Float, 8);
            parameters[19] = new SqlParameter("@pro_Stock", SqlDbType.Int, 4);
            parameters[20] = new SqlParameter("@pro_Unit", SqlDbType.VarChar, 50);
            parameters[21] = new SqlParameter("@pro_Alarm", SqlDbType.Int, 4);
            parameters[22] = new SqlParameter("@pro_AuditCount", SqlDbType.Int, 4);
            parameters[23] = new SqlParameter("@pro_Audit", SqlDbType.Int, 4);
            parameters[24] = new SqlParameter("@pro_State", SqlDbType.VarChar, 200);
            parameters[25] = new SqlParameter("@pro_Designation", SqlDbType.VarChar, 100);
            parameters[26] = new SqlParameter("@pro_RelatingproID", SqlDbType.VarChar, 1000);
            parameters[27] = new SqlParameter("@pro_RelatingArtID", SqlDbType.VarChar, 1000);
            parameters[28] = new SqlParameter("@pro_UpdateTime", SqlDbType.DateTime);
            parameters[29] = new SqlParameter("@pro_OnClicks", SqlDbType.Int, 4);
            parameters[30] = new SqlParameter("@pro_SaleNum", SqlDbType.Int, 4);
            parameters[31] = new SqlParameter("@pro_CostPrice", SqlDbType.Float, 8);
            parameters[32] = new SqlParameter("@pro_AutoUp", SqlDbType.DateTime);
            parameters[33] = new SqlParameter("@pro_AutoDown", SqlDbType.DateTime);
            parameters[34] = new SqlParameter("@pro_IntegralPrice", SqlDbType.Float, 8);
            parameters[35] = new SqlParameter("@pro_Area", SqlDbType.VarChar, 50);
            parameters[36] = new SqlParameter("@pro_PutoutID", SqlDbType.Int, 4);
            parameters[37] = new SqlParameter("@pro_PutoutType", SqlDbType.Int, 4);
            parameters[38] = new SqlParameter("@pro_ContentTemplate", SqlDbType.VarChar, 100);
            parameters[39] = new SqlParameter("@pro_Specifications", SqlDbType.Text);
			parameters[40] = new SqlParameter("@pro_Parameters", SqlDbType.Text);
            parameters[41] = new SqlParameter("@pro_Type", SqlDbType.Int, 4);
            parameters[42] = new SqlParameter("@pro_Specialspecifications",SqlDbType.VarChar,200);

            parameters[0].Value = model.pro_ID;
            parameters[1].Value = model.pro_Property;
            parameters[2].Value = model.pro_CID;
            parameters[3].Value = model.pro_BrandID;
            parameters[4].Value = model.pro_Name;
            parameters[5].Value = model.pro_NO;
            parameters[6].Value = model.pro_ShopPrice;
            parameters[7].Value = model.pro_MarketPrice;
            parameters[8].Value = model.pro_RatingDiscount;
            parameters[9].Value = model.pro_DonateIntegral;
            parameters[10].Value = model.pro_Thumbnail;
            parameters[11].Value = model.pro_Images;
            parameters[12].Value = model.pro_Original;
            parameters[13].Value = model.pro_Synopsis;
            parameters[14].Value = model.pro_Content;
            parameters[15].Value = model.pro_MetaKeywords;
            parameters[16].Value = model.pro_MetaDescription;
            parameters[17].Value = model.pro_MetaTitle;
            parameters[18].Value = model.pro_Weight;
            parameters[19].Value = model.pro_Stock;
            parameters[20].Value = model.pro_Unit;
            parameters[21].Value = model.pro_Alarm;
            parameters[22].Value = model.pro_AuditCount;
            parameters[23].Value = model.pro_Audit;
            parameters[24].Value = model.pro_State;
            parameters[25].Value = model.pro_Designation;
            parameters[26].Value = model.pro_RelatingproID;
            parameters[27].Value = model.pro_RelatingArtID;
            parameters[28].Value = model.pro_UpdateTime;
            parameters[29].Value = model.pro_OnClicks;
            parameters[30].Value = model.pro_SaleNum;
            parameters[31].Value = model.pro_CostPrice;
            parameters[32].Value = model.pro_AutoUp;
            parameters[33].Value = model.pro_AutoDown;

            parameters[34].Value = model.pro_IntegralPrice;
            parameters[35].Value = model.pro_Area;
            parameters[36].Value = model.pro_PutoutID;
            parameters[37].Value = model.pro_PutoutType;
            parameters[38].Value = model.pro_ContentTemplate;
            parameters[39].Value = model.pro_Specifications;
            parameters[40].Value = model.pro_Parameters;
            parameters[41].Value = model.pro_Type;
            parameters[42].Value = model.pro_Specialspecifications;
            return parameters;
        }

        public IDbDataParameter[] ValueIDPara(int id)
        {
            SqlParameter[] paras = new SqlParameter[1];
            paras[0] = new SqlParameter("@pro_ID", id);
            paras[0].DbType = DbType.Int32;
            return paras;
        }


        #endregion
    }
}

